#ifdef USE_RKNN



#ifndef _RKNN_YOLOV8_DEMO_POSTPROCESS_H_
#define _RKNN_YOLOV8_DEMO_POSTPROCESS_H_

#include <stdint.h>
#include <vector>
#include "rknn_api.h"
#include "common.h"
#include "image_utils.h"

#define OBJ_NAME_MAX_SIZE 64
#define OBJ_NUMB_MAX_SIZE 128
#define OBJ_CLASS_NUM 80
#define NMS_THRESH 0.45
#define BOX_THRESH 0.25


#if defined(RV1106_1103) 
typedef struct {
	char* dma_buf_virt_addr;
	int dma_buf_fd;
	int size;
}rknn_dma_buf;
#endif

typedef struct {
	rknn_context rknn_ctx;
	rknn_input_output_num io_num;
	rknn_tensor_attr* input_attrs;
	rknn_tensor_attr* output_attrs;
#if defined(RV1106_1103) 
	rknn_tensor_mem* input_mems[1];
	rknn_tensor_mem* output_mems[9];
	rknn_dma_buf img_dma_buf;
#endif
#if defined(ZERO_COPY)  
	rknn_tensor_mem* input_mems[1];
	rknn_tensor_mem* output_mems[9];
	rknn_tensor_attr* input_native_attrs;
	rknn_tensor_attr* output_native_attrs;
#endif
	int model_channel;
	int model_width;
	int model_height;
	bool is_quant;
} rknn_app_context_t;


typedef struct {
    image_rect_t box;
    float prop;
    int cls_id;
} object_detect_result;

typedef struct {
    int id;
    int count;
    object_detect_result results[OBJ_NUMB_MAX_SIZE];
} object_detect_result_list;


int init_post_process(const char * strLabelPath ="");
void deinit_post_process();
char *coco_cls_to_name(int cls_id);
int post_process(rknn_app_context_t *app_ctx, void *outputs, letterbox_t *letter_box, float conf_threshold, float nms_threshold, object_detect_result_list *od_results);

void deinitPostProcess();
#endif //_RKNN_YOLOV8_DEMO_POSTPROCESS_H_



#endif //USE_RKNN